<?php 
     class ShopController extends Controller{

     	private $model;

     	public function __init(){
     		$this->model = K('Shop');
     	}
     	function index(){	

     		$defaultData = $this->model->get_data(array('mid'=>Q('get.mid',0,'intval')));

     		$this->assign('defaultData',$defaultData);
     		$this->display();
     	}


     	function add(){
     		if(IS_POST){
     		if(!$this->model->create()) $this->error($this->model->error);
     		if(!$this->model->add_shop()){
     			$this->error($this->model->error);
     		}

     		$this->success('添加成功',U('index',array('mid'=>Q('post.mid',0,'intval'))));
     		}
     		$this->display();
     	}


     	function edit_cate(){
     		if(IS_POST){
     			if(!$this->model->create()) $this->error($this->model->error());
     			$this->model->update_data(array('sid'=>Q('post.sid',0,'intval')));
     				
     			
     			$this->success('修改成功',U('Index',array('mid'=>Q('post.mid',0,'intval'))));
     		}
     	$oldData=$this->model->get_one_data(array('sid'=>Q('get.sid',0,'intval(var)')));
     	$this->assign('oldData',$oldData);
     		$this->display();
     	}


     	function del(){
     		$this->model->del_data(array('sid'=>Q('get.sid',0,'intval')));
     		$this->success('删除成功',U('index',array('mid'=>Q('get.mid',0,'intval'))));
     	}


     }



 ?>